package com.hub.frame.utils.contextHolder;

/**
 * @author hub
 * 认证用threadLocal、存储userId、deviceId
 */
public class AppContextHolder {

    private static final ThreadLocal<String> userIdContextHolder = new ThreadLocal<>();

    private static final ThreadLocal<String> userNameContextHolder = new ThreadLocal<>();

    private static final ThreadLocal<String> roleIdContextHolder = new ThreadLocal<>();

    private static final ThreadLocal<String> supplierIdContextHolder = new ThreadLocal<>();

    // 读取userId
    public static String getUserId() {
        return userIdContextHolder.get();
    }

    // 设置userId
    public static void setUserId(String value) {
        userIdContextHolder.set(value);
    }

    // 清除userId
    public static void removeUserId() {
        userIdContextHolder.remove();
    }

    // 读取userName
    public static String getUserName() {
        return userNameContextHolder.get();
    }

    // 设置userName
    public static void setUserName(String value) {
        userNameContextHolder.set(value);
    }

    // 清除userName
    public static void removeUserName() {
        userNameContextHolder.remove();
    }

    // 读取roleId
    public static String getRoleId() {
        return roleIdContextHolder.get();
    }

    // 设置roleId
    public static void setRoleId(String value) {
        roleIdContextHolder.set(value);
    }

    // 清除roleId
    public static void removeRoleId() {
        roleIdContextHolder.remove();
    }

    // 读取supplierId
    public static String getSupplierId() {
        return supplierIdContextHolder.get();
    }

    // 设置supplierId
    public static void setSupplierId(String value) {
        supplierIdContextHolder.set(value);
    }

    // 清除supplierId
    public static void removeSupplierId() {
        supplierIdContextHolder.remove();
    }
}
